﻿using System;

using System.Collections.Generic;
using System.Text;
using DirectUI.Mobile.UI.Controls;
using System.ComponentModel;

namespace DirectUI.Mobile.UI.Controls
{
  
        public class PageCollection : BindingList<Page>
        {
            public PageCollection(NavigationPanel tabPanel)
                : base()
            {
                this.tabPanel = tabPanel;
                
            }

            private NavigationPanel tabPanel;

            protected override void OnListChanged(ListChangedEventArgs e)
            {
                base.OnListChanged(e);
                switch (e.ListChangedType)
                {
                    case ListChangedType.ItemAdded:
                        tabPanel.Controls.Add(this[e.NewIndex]);
                        break;

                    case ListChangedType.ItemDeleted:
                        tabPanel.Controls.RemoveAt(e.OldIndex);
                        break;
                }
            }

            protected override void ClearItems()
            {
                tabPanel.Controls.Clear();
                base.ClearItems();
            }
        }
 
}
